 <? include("header.php" ) ?>
 
<?php 
//validate_user(); 

if(isset($_SESSION['business_url'])&&(!empty($_SESSION['business_url']))){ 
	$sql=mysql_query("INSERT INTO `my_business_page_url` SET `userid`='".$_SESSION['id']."' ,`cat_id`='".$_SESSION['cat_id']."',
															`url`='".mysql_real_escape_string($_SESSION['business_url'])."' ")or die(mysql_error());
	$id=mysql_insert_id();
	if($sql){
		unset($_SESSION['business_url']);
		unset($_SESSION['cat_id']);
		$_SESSION['url_id']=$id;
	}
}
//Submit Url///////////////////////////////////////////////////////////
if(isset($_POST['submit_fanpage_x'])){ 
	$sql=mysql_query("UPDATE `my_business_page_url` SET `page_url`='".$_POST['page_url']."',`page_height`='".$_POST['height']."'
														WHERE `id`='".$_SESSION['url_id']."' ")or die(mysql_error());
	if($sql){
		$_SESSION['url']=1;
		header("location:".$_SERVER['HTTP_REFERER']); exit;
	}
}
//Submit Artical ///////////////////////////////////////////////////
if(isset($_POST['submit_artical'])){ 
	$sql=mysql_query("UPDATE `my_business_page_url` SET `article_title`='".addslashes($_POST['title'])."',
												   `article_discription`='".addslashes($_POST['artical'])."',
												   `fetured_image`=''
												 	WHERE `id`='".$_SESSION['url_id']."'  ")or die(mysql_error());
	if($sql){
		$_SESSION['url']=1;
		header("location:".$_SERVER['HTTP_REFERER']); exit;
	}
}
//Submit About//////////////////////////////////////////////
if(isset($_POST['Submit_about_x'])){ //print_r($_POST); die();
	$base_name = basename($_FILES['photo']['name']);
	$photos='';
	if($base_name!="" && $_FILES['photo']['error']==0 && $_FILES['photo']['size']<(1024*1024)/2){
		$path="uploads/";
		$thumb_folder_path = "uploads/thumb/";
		$tt=time();
		$target_path=$path.$tt.$base_name;
		$thumb_target_path = $thumb_folder_path."t_".$tt.$base_name;
		$photo=$tt.$base_name;
		$photos =" `profile_image` = '".$photo."', "; 
		if(move_uploaded_file($_FILES['photo']['tmp_name'],$target_path)){
			echo $old_img=get_item('my_business_page_url','id',$_SESSION['url_id'],'profile_image');
			if(!empty($old_img)){
				unlink("uploads/".$old_img);
				//unlink("uploads/thumb/t_".$old_img);	
			}			
			/*$image = new SimpleImage();
			$image->load($target_path);
			$image->resize(500,500);
			$image->save($thumb_target_path);*/
		}
	}else{
		$_SESSION['msg']="Please select an image 500px X 500px in dimention and below 1/2 mb in size to upload!";
		header("location:".$_SERVER['HTTP_REFERER']); exit;	
	}
	$sql=mysql_query("UPDATE `my_business_page_url` SET `title`='".addslashes($_POST['title'])."',
												   `description`='".addslashes($_POST['description'])."',
												   `website`='".$_POST['website']."',
												   `email`='".$_POST['email']."',
												   `phone`='".$_POST['phone']."', $photos `status` = 1
												 	WHERE `id`='".$_SESSION['url_id']."'  ")or die(mysql_error());
	if($sql){
		$_SESSION['url']=1;
		header("location:".$_SERVER['HTTP_REFERER']); exit;
	}
} 
/////////////////////////////////////////////////////////////
if(isset($_SESSION['url_id'])){ $url=get_allitem('my_business_page_url','id',$_SESSION['url_id']); }

?>

<!--Body Section start-->
<div class="body_div" style="margin: 0 auto; float:none;">
<div class="create_page_head">
<h1><a href="http://www.mycitydial.com/<?php if(isset($url['url'])){ echo $url['url'];} ?>" target="_blank">http://www.mycitydial.com/<?php if(isset($url['url'])){ echo cut_text($url['url'],75);} ?></a></h1>
<select  class="active_option" name="publish" onchange="publish(this.value);">
<option value="1"<?php if(isset($url['status'])&&($url['status']==1)){ echo "selected='selected'";} ?> >Active</option>
<option  value="0" <?php if(isset($url['status'])&&($url['status']==0)){ echo "selected='selected'";} ?>>Deactive</option>
</select>
</div>

<!--Create page Steps div start-->
<div class="steps_div">
<div class="steps">
<ul>
<li><a href="#" class="<?php if(isset($_REQUEST['url'])&&($_REQUEST['url']!="")){ echo "active ";} ?>">
<div>
<img src="images/steps/1.png" />
<span>Add URL</span>
</div>
</a></li>

<li><a href="#" class="<?php if(isset($_REQUEST['url'])&&($_REQUEST['url']!="")){ echo "active ";} ?>">
<div><img src="images/steps/2.png" />
<span>Gallery</span>
</div>
</a></li>

<li><a href="#">
<div>
<img src="images/steps/3.png" />
<span>Artical</span>
</div>
</a></li>

<li><a href="#">
<div><img src="images/steps/4.png" />
<span>About </span>
</div>
</a></li>
</ul>
</div>
<ul id="output2">
<li>
<div class="setps_form_heading">
<form action="" method="post" id="fanpage" >
 <div class="add_url">
 <span>Page URL</span>
 <input name="page_url" type="text" class="add_url_box" value="<?php if(isset($url['page_url'])&&($url['page_url']!="")){echo $url['page_url']; }else{ echo "http://www.yoursitename.com/fanpage.html  (example)"; } ?>" onfocus="if (this.value==this.defaultValue) this.value = ''" onblur="if (this.value=='') this.value = this.defaultValue" required="required" />
 </div>
 
  <div class="add_url_width">
 <span>Width (px)</span>
 <input name="width" type="text" class="width_box" value="750" disabled="disabled" />
 </div>
 
   <div class="add_url_width">
 <span>Height (px)</span>
 <input type="hidden" name="url_id" value="<?php if(isset($_SESSION['url_id'])){ echo $_SESSION['url_id'];} ?>" onfocus="if (this.value==this.defaultValue) this.value = ''" onblur="if (this.value=='') this.value = this.defaultValue"/>
 <input name="height" type="text" class="width_box" value="<?php if(isset($url['page_height'])&&($url['page_height']!=0)){echo $url['page_height']; }else{ echo "750"; } ?>" required="required" />
 </div>
 <div class="add_url_bt">
 
 <input name="submit_fanpage"  value="Add Url" type="button" class="inputbtn" style="padding-top:3px; padding-bottom:3px;"  /> 
 
 </div>
</form>
</div>

 <div class="artical">
 <?php if(isset($url['page_url'])){?>
 <iframe src="<?php echo $url['page_url']; ?>" height="<?php echo $url['page_height']; ?>" width="750" scrolling="no"></iframe>
 <?php }?>
 </div>
</li>

<!--.......................-->
<li>
<div class="setps_form_heading">
<div class="tab_name">
<span>Gallery Tab Name</span>
<form  style="height:0px; width:0px; overflow:hidden;"id="imageform" method="post" enctype="multipart/form-data" action='ajaximage.php'>
  <input type="file" name="item_file[]" id="photoimg" multiple='multiple' />
</form>
<input name="gallery_title" id="gallery_title" type="text" class="tab_box" value="<?php if(isset($url['website'])){ echo $url['website'];}else{echo "New Gallery Name";} ?>" />
</div>
<div class="add_photo"><img onclick="$('#photoimg').click()" src="images/add_photo.png" />
<div class="wait"></div>

 


 

</div>
</div>

<!--Photo Gallery start-->
<div class="photo_gallery">
<?php $sql=mysql_query("SELECT * FROM `my_images` WHERE `url_id` ='".$_SESSION['url_id']."'")or die(mysql_error());
while($row=mysql_fetch_array($sql)){
?>
<section class='photo_section'>
<div class='photo_main'><img src='uploads/<?php echo $row['image']; ?>' height='172' width='138'  ></div>
<div class='photo_select'><img src="images/delete_bt.png" onclick="deleteimg(this,'<?php echo $row['id']; ?>');" style="float: left;margin-right: 4px;" />
<span> <p class="alt_txt"><?php echo $row['alt_text']; ?></p> 
<input type='text' value='<?php echo $row['alt_text']; ?>'name='alt_text' onblur='save_alt_text(this,this.value,'<?php echo $row['id']; ?>');' id='alt_text' style='width: 109px;margin-top: -5px;display:none;'/></span> 
</div>
</section>
<?php }?>
</div>
<!--Photo  Gallery end-->
</li>
<!--.......................-->

<li>
<form action="" method="post" enctype="multipart/form-data" id="artical_form">
<div class="setps_form_heading">

<div class="artical_name">
<span>Artical Title</span>
<input name="title" type="text" class="artical_name_box" 
value="<?php if(isset($url['article_title'])){ echo $url['article_title']; }else{ echo "Write your  Artical Titel Here!"; } ?>" />
</div>

<div class="artical_bt">
<span>Upload Featured Images</span>
<div id="file_browse_wrapper" style="margin-left:0px;">
<input name="fetured_image" id="file_browse" type="file" />
</div>
</div>
</div>

<div class="artical">
<script type="text/javascript"  src="editor/ckeditor.js"></script>
<script>
$(function(){
	CKEDITOR.replace( 'editor1' );
	})
	
</script>
<textarea name="artical" class="textarea"  id="editor1" style="border: 1px #C7E0E3 solid"><?php if(isset($url['article_discription'])){ echo $url['article_discription'];} ?></textarea><br />  <br /> 



<input name="submit_artical" style="float:right;" class="inputbtn" type="button" value="Submit"/>

</div>
</form>
</li>
<!--.......................-->

<li>
<form action="" method="post" enctype="multipart/form-data" id="about_form">
<div class="about_form">
<dl>
<dt>Profile Picture</dt>
<dd><input name="photo" type="file" class="profile_box"  />
<img src="<?php if(!empty($url['profile_image'])){ echo "uploads/".$url['profile_image'];}else{echo "images/noimage.jpg";} ?>" width="30" height="30" style="float:left; padding-left:20px;" />
<span>500 px   x  500px</span>
</dd>
</dl>

<dl>
<dt>Page Title</dt>
<dd><input name="title" type="text" class="long_box"  value="<?php if(isset($url['title'])){ echo $url['title'];} ?>"  />
</dd>
</dl>

<dl class="tip">
<dt>Tip: Add a description and website to improve the ranking of your page in search.</dt>
<dd><textarea class="tips_area" name="description" ><?php if(isset($url['description'])){ echo $url['description'];} ?></textarea></dd>
</dl>

<dl>
<dt>Website </dt>
<dd><input name="website" type="text" class="long_box" value="<?php if(isset($url['website'])){ echo $url['website'];} ?>"  />
</dd>
</dl>

<dl>
<dt>Email Address</dt>
<dd><input name="email" type="text" class="long_box"  value="<?php if(isset($url['email'])){ echo $url['email'];} ?>"  />
</dd>
</dl>

<dl>
<dt>Phone number</dt>
<dd><input name="phone" type="text" class="phone_box"  value="<?php if(isset($url['phone'])){ echo $url['phone'];} ?>" />
</dd>
</dl>

<dl>
<dt>&nbsp;</dt>
<dd><input name="agree" type="checkbox" style="float:left;" value="1"  /> <span class="agree">I am Agree with this Tearms & condtions</span></dd>
</dl>

<dl>
<dt>&nbsp;</dt>
<dd><input name="Submit_about" type="button" value="Publish" class="inputbtn"  /></dd>
</dl>

</div>
</form>
</li>

</ul>
</div>
<!--Create page Steps div end-->
<br clear="all" />
<br clear="all" />
</div>
<? include("footer.php");  ?>

